package com.nanfang51g3.ckz.ui.base;

import com.nanfang51g3.ckz.utils.KLog;

import rx.Subscription;
import rx.subscriptions.CompositeSubscription;

/**
 * 注销rx
 * Created by Administrator on 2016/7/12.
 */
public abstract class BasePresenter implements IPresenter {
    protected CompositeSubscription mCompositeSubscription;

    protected void unSubscribe() {
        KLog.i("Evd", "执行-unSubscribe");
        if (mCompositeSubscription != null) {
            KLog.i("Evd", "执行-if");
            mCompositeSubscription.unsubscribe();
        }
    }

    protected void addSubscrebe(Subscription subscription) {
        KLog.i("Evd", "执行-addSubscrebe");
        if (mCompositeSubscription == null) {
            KLog.i("Evd", "执行-if");
            mCompositeSubscription = new CompositeSubscription();
        }
        mCompositeSubscription.add(subscription);
    }

    @Override
    public void detachView() {
        unSubscribe();
    }
}
